package com.etc.view;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;

public class Mypanel extends JPanel {
	int y1 = 0;
	int y2 = 0;

	public void paint(Graphics g) {
		Image bg;
		ImageIcon icon;
		super.paint(g);
		icon = new ImageIcon("pic/timg2.PNG");
		bg = icon.getImage();
		g.drawImage(bg, 220, 20, null);
		paintComponents(g);
		g.setColor(Color.white);
		Graphics2D g2 = (Graphics2D)g;
		g2.setStroke(new BasicStroke(3.0f));  
		g.drawOval(320, 120, 50, 50);
		g.drawLine(345, 170, 345, 275);
		g.drawLine(345, 200, 295, 250);
		g.drawLine(345, 200, 395, 250 + y1);
		g.drawLine(345, 275, 295, 325);
		g.drawLine(345, 275, 395, 325);
	
		
		g.drawOval(730, 120, 50, 50);
		g.drawLine(755, 170, 755, 275);
		g.drawLine(755, 200, 705, 250 + y2);
		g.drawLine(755, 200, 805, 250);
		g.drawLine(755, 275, 705, 325);
		g.drawLine(755, 275, 805, 325);

	}
	
	public void changeLeft() {
		while (true) {
				y1--;
				if (250 + y1 == 150) {
					y1 = 0;
					break;
				}
				try {
					Thread.sleep(5);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				repaint();
			}
	}
	
	public void changeRight() {
		while (true) {
				y2--;
				if (250 + y2 == 150) {
					y2 = 0;
					break;
				}
				try {
					Thread.sleep(5);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				repaint();
			}
	}
	



}
